<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>float</title>
    <style>
        body {
            font-family: '微软雅黑';
        }

        .main {
            border: 12px red solid;
        }

        .div1 {
            float: left;
            border: 12px #161cff solid;
            width: 100px;
            height: 100px;
        }

        .div2 {
            float: left;
            border: 15px #00ff14 solid;
            width: 100px;
            height: 100px;
        }

        .div3 {
            float: left;
            border: 16px #72001a solid;
            width: 100px;
            height: 100px;
        }

        .clearfix:after {/*具体看html-伪元素,就知道原理了*/
            content:",";
            height:0;
            display:block;
            visibility:hidden;
            clear:both;
        }
        .clearfix{
            zoom:1;/*清除浮动 兼容ie浏览器*/
        }
    </style>
</head>
<body>
<div class="main clearfix">
    <div class="div1">div1</div>
    <div class="div2">div2</div>
    <div class="div3">div3</div>
</div>
</body>
</html>